<?php use_helper('jQuery', 'I18N', 'Date') ?>

<div id="importar" title="<?php echo __("Importar fichero de datos")?>">
    <span>
        <span class="label">
            <?php echo __("Seleccione el fichero de datos que desea importar.")?>
        </span>
        <span>
            <form action="<?php echo url_for('inicio/importarCSV') ?>" enctype="multipart/form-data" method="POST" id="form_fichero">
                <table>
                    <tr>
                        <th><label for="fichero">Fichero</label></th>
                        <!--<td><input type="file" name="fichero" id="fichero" /></td>-->
                        <td><?php echo $form['filename']->renderError() ?>
                            <?php echo $form['filename'] ?></td>                            
                    </tr>
                </table>
            </form>     
        </span>
    </span>
</div>

<!--?php include_partial('form', array('form' => $form)) ?-->


<script language="JavaScript" type="text/javascript">
  	$(function() {
  		var aceptar = function () {
			$('#form_fichero').submit();
  		};
  		var cancelar = function () {
  			$("#importar").dialog("destroy");
			$("#importar").remove();
			window.location = "<?php echo url_for('@inicio'); ?>";
  		};

  		var dialogOpts = {
  			autoOpen: true,
  			width:500,
  			minHeight:300,
  			closeOnEscape: true,
  			modal: true,
  			buttons: {
  	  			"<?php echo __("Guardar")?>": aceptar,
  				"<?php echo __("Cancelar")?>": cancelar
  			},
                        resizable: false,
                        close: function() { location.href = "<?php echo url_for('@inicio'); ?>" },
  			open: function() {
                                $(this).parents('.ui-dialog-buttonpane button:eq(3)').focus();
                        }
  		};
  		$("#importar").dialog(dialogOpts);
	});
  </script>
